package com.zhufeng.gateway.balancer.config;

import com.zhufeng.gateway.balancer.filter.GrayReactiveLoadBalancerClientFilter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.gateway.config.LoadBalancerProperties;
import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName: GrayGatewayReactiveLoadBalancerClientAutoConfiguration
 * @Description TODO
 * @author 月夜烛峰
 * @date 2022/10/8 15:40
 */
@Slf4j
@Configuration
public class GrayGatewayReactiveLoadBalancerClientAutoConfiguration {
    public GrayGatewayReactiveLoadBalancerClientAutoConfiguration() {
    }

    @Bean
    @ConditionalOnMissingBean({GrayReactiveLoadBalancerClientFilter.class})
    public GrayReactiveLoadBalancerClientFilter grayReactiveLoadBalancerClientFilter(LoadBalancerClientFactory clientFactory, LoadBalancerProperties properties) {
        log.info("初始化完成....");
        return new GrayReactiveLoadBalancerClientFilter(clientFactory, properties);
    }
}
